<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
defined('_JEXEC') or die('Restricted access');
?>
<div class="vast-article_wrap clearfix">
<div class="vast-articleflow">
   <?php
   
   $datetimes = $params->get('datetime',1); 
   $random = $params->get('random',1);
   if($random == 1)
   {
       shuffle($list);
   }
   //Hien thi nut doc them
   $btnread = $params->get('btnreadmore');
   
   
   
   //
    $number = trim($params->get('textnumber'));
    $number2 = trim($params->get('textnumber2'));
   //Lay chieu rong va chieu cao cua anh thong qua tham so "width_height"
    $arr = array();
    $width_height = trim($params->get('width_height'));
    $arr = explode('-',$width_height);
    $width = $arr[0];
    $height= $arr[1];
   //Hien thi hinh anh
    $showimage = $params->get('showimage');
    
    
    $img = null;
   for ($i=0, $n=count($list); $i<1;$i++) {
        $row = $list[$i];
         $img = modArticleflowHelper::str_img_scr($row->introtext);
        if (count($img) == 0) {
            $img = modArticleflowHelper::str_img_scr($row->fulltext);
            if(count($img) != 0){
                  $introtext = str_replace('<img src="'.$img[0].'" border="0" width="140" height="125"/>', '', $row->introtext);
            }
            else
                $introtext = $row->introtext;
          
             
        }
        else
        {
            $introtext = str_replace('<img src="'.$img[0].'" border="0" />', '', $row->introtext);
        }
       
        //So luong tu hien thi tren tin dau tien
        $str = strip_tags($introtext);
        $temp = explode(' ', $str);
        $abc = ' ';
         //print_r($img[0]); die();

   //}
    //foreach ($list as $item) {

            //$link = JRoute::_('index.php?option=com_detai&view=detai&id=' . $item->slug . '&catid=' . $item->gslug);
?>
                <h2 class="title"><a href="<?php echo $row->link; ?>">
            <?php echo $row->text . ' '; ?></a></h2><div class="dt"><span class="datetime"><?php if($datetimes == 1) {  echo '(' .  date('d-m-Y H:m', strtotime($row->created)).')';}?></span></div> <?php if(count($img) !=0 ){?><img src="<?php echo $img[0];?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>"/><?php } ?>
                <?php
                    $text = array();
                    for($j=0;$j<$number; $j++)
                    {
                        $text[] = $temp[$j];
                    }
                echo implode(' ', $text); 
                ?><br>
            <a href="<?php echo $row->link; ?>" class="readon">Đọc thêm...</a>
    
    <?php } ?>

</div>
<div class ="vast-articleflow-list">
<ul class="<?php echo $params->get('moduleclass_sfx'); ?>"><?php
   // foreach ($list as $items) {       
   $introtext = array();
        for ($i=1, $n=count($list); $i<$n;$i++) {
            $row = $list[$i];
             $img2 = modArticleflowHelper::str_img_scr($row->introtext);
        if (count($img2) == 0) {
            $img2 = modArticleflowHelper::str_img_scr($row->fulltext);
            if(count($img2) != 0){
                $introtext = str_replace('<img src="'.$img2[0].'" border="0"/>', '', $row->introtext   );
            }
            else
                $introtext = $row->introtext;
        }
        else
        {
            $introtext = str_replace('<img src="'.$img2[0].'" border="0"/>', '', $row->introtext);
        }
        
        //so luong tu hien thi tren tin con lai
        //
        
        $str = strip_tags($introtext);
      
        $temp = explode(' ', $str);
         // print_r($temp); //die();
      
//foreach ($row as $item) {
            //$link = JRoute::_('index.php?option=com_detai&view=detai&id=' . $item->slug . '&catid=' . $item->gslug);
?>
            <li>
                <a href="<?php echo $row->link;?>">
            <?php echo $row->text .' '; ?></a><div class="dt"><span class="datetime"><?php if($datetimes ==1) { echo '(' .  date('d-m-Y H:m', strtotime($row->created)) . ')';}?></span></div><div class="content"><?php if($showimage ==0 ) {if(count($img2) !=0 ){?><img src="<?php echo $img2[0];?>" width="60" height="60" style="float: left;"/><?php }} ?>
            <?php
                    $text = array();
                    for($j=0;$j<$number2; $j++)
                    {
                        $text[] = $temp[$j];
                    }
                echo implode(' ', $text);
                if($btnread == 1 && $number2 !=0)
                {?>
            <a href="<?php echo $row->link; ?>" class="readon">Đọc thêm...</a>
                    <?php
                }
            ?>
            </div>
    </li>
	<span class="article_separator">&nbsp;</span>
    <?php }//} }?>
</ul>
</div>
</div>